<?php
/*********************/
/*                   */
/*  Version : 5.1.0  */
/*  Author  : RM     */
/*  Comment : 071223 */
/*                   */
/*********************/

define( "JIEQI_MODULE_NAME", "system" );
require_once( "../global.php" );
include_once( JIEQI_ROOT_PATH."/class/power.php" );
$power_handler =& jieqipowerhandler::getinstance( "JieqiPowerHandler" );
$power_handler->getsavedvars( "system" );
jieqi_checkpower( $jieqiPower['system']['adminuserlog'], $jieqiUsersStatus, $jieqiUsersGroup, false, true );
include_once( JIEQI_ROOT_PATH."/class/userlog.php" );
$userlog_handler = jieqiuserloghandler::getinstance( "JieqiUserlogHandler" );
jieqi_getconfigs( JIEQI_MODULE_NAME, "configs" );
if ( empty( $_REQUEST['page'] ) || !is_numeric( $_REQUEST['page'] ) )
{
		$GLOBALS['_REQUEST']['page'] = 1;
}
include_once( JIEQI_ROOT_PATH."/admin/header.php" );
$criteria = new criteriacompo( );
if ( !empty( $_REQUEST['keyword'] ) )
{
		if ( $_REQUEST['keytype'] == 1 )
		{
				$criteria->add( new criteria( "toname", $_REQUEST['keyword'], "=" ) );
		}
		else
		{
				$criteria->add( new criteria( "fromname", $_REQUEST['keyword'], "=" ) );
		}
}
$criteria->setsort( "logid" );
$criteria->setorder( "DESC" );
$criteria->setlimit( $jieqiConfigs['system']['userlogpnum'] );
$criteria->setstart( ( $_REQUEST['page'] - 1 ) * $jieqiConfigs['system']['userlogpnum'] );
$userlog_handler->queryobjects( $criteria );
$logrows = array( );
$k = 0;
while ( $v = $userlog_handler->getobject( ) )
{
		$logrows[$k]['date'] = date( JIEQI_DATE_FORMAT, $v->getvar( "logtime" ) );
		$logrows[$k]['time'] = date( JIEQI_TIME_FORMAT, $v->getvar( "logtime" ) );
		$logrows[$k]['fromid'] = $v->getvar( "fromid" );
		$logrows[$k]['fromname'] = $v->getvar( "fromname" );
		$logrows[$k]['toid'] = $v->getvar( "toid" );
		$logrows[$k]['toname'] = $v->getvar( "toname" );
		$logrows[$k]['reason'] = $v->getvar( "reason" );
		$logrows[$k]['chginfo'] = $v->getvar( "chginfo" );
		++$k;
}
$jieqiTpl->assign_by_ref( "logrows", $logrows );
include_once( JIEQI_ROOT_PATH."/lib/html/page.php" );
$jumppage = new jieqipage( $userlog_handler->getcount( $criteria ), $jieqiConfigs['system']['userlogpnum'], $_REQUEST['page'] );
$jumppage->setlink( "", true, true );
$jieqiTpl->assign( "url_jumppage", $jumppage->whole_bar( ) );
$jieqiTpl->setcaching( 0 );
$jieqiTset['jieqi_contents_template'] = JIEQI_ROOT_PATH."/templates/admin/userlog.html";
include_once( JIEQI_ROOT_PATH."/admin/footer.php" );
?>
